﻿using Huirui.Cavan.Domain.Seedwork;
using System;
using System.Collections;
using System.Collections.Generic;
using Huirui.Cavan.Domain.MainBoundedContext.StockModule;

namespace Huirui.Cavan.Domain.MainBoundedContext.SystemModule
{
    #region Department

    /// <summary>
    /// Department object for NHibernate mapped table 'Department'.
    /// </summary>
    [Serializable]
    public class Department : Persistent<string>
    {
        #region Member Variables

        protected string _name;
        protected string _remark;
        protected Corporation _corporation;
        protected IList<Employee> _employees;
        protected IList<StockInOut> _stockIns;
        protected IList<StockOutApply> _stockOutApplies;
        protected IList<WareHouse> _wareHouses;
        protected string _superiorDepartment;
        #endregion

        #region Constructors

        public Department() { }

        public Department(string code,string name, string remark,string superiorDepartment, DateTime createDate, DateTime modifyDate, int editUser, Corporation corporation)
        {
            this.Id = code;
            this._name = name;
            this._remark = remark;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._editUser = editUser;
            this._corporation = corporation;
            this._superiorDepartment = superiorDepartment;
        }

        #endregion

        #region Public Properties

        public virtual string Name
        {
            get { return _name; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
                _name = value;
            }
        }

        public virtual string Remark
        {
            get { return _remark; }
            set
            {
                _remark = value;
            }
        }

        public virtual string SuperiorDepartment
        {
            get { return _superiorDepartment; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for SuperiorDepartment", value, value.ToString());
                _superiorDepartment = value;
            }
        }

        public virtual Corporation Corporation
        {
            get { return _corporation; }
            set { _corporation = value; }
        }

        public virtual IList<Employee> Employees
        {
            get
            {
                if (_employees == null)
                {
                    _employees = new List<Employee>();
                }
                return _employees;
            }
            set { _employees = value; }
        }

        public virtual IList<StockInOut> StockIns
        {
            get
            {
                if (_stockIns == null)
                {
                    _stockIns = new List<StockInOut>();
                }
                return _stockIns;
            }
            set { _stockIns = value; }
        }

        public virtual IList<StockOutApply> StockOutApplies
        {
            get
            {
                if (_stockOutApplies == null)
                {
                    _stockOutApplies = new List<StockOutApply>();
                }
                return _stockOutApplies;
            }
            set { _stockOutApplies = value; }
        }

        public virtual IList<WareHouse> WareHouses
        {
            get
            {
                if (_wareHouses == null)
                {
                    _wareHouses = new List<WareHouse>();
                }
                return _wareHouses;
            }
            set { _wareHouses = value; }
        }
        #endregion
    }
    #endregion
}